1 00:00:00,700 --> 00:00:03,270 Today, I'm going to reset my trap. 2 00:00:03,280 --> 00:00:08,290 In the last video, we made it so that when you step on the pressure plate, the boulder will roll down 3 00:00:08,290 --> 00:00:10,620 the hill and off into the world. 4 00:00:10,630 --> 00:00:12,580 But we need to reset our trap. 5 00:00:12,580 --> 00:00:14,380 So let's go ahead and get started with that. 6 00:00:14,380 --> 00:00:15,910 Let's go to workspace. 7 00:00:16,060 --> 00:00:17,740 We'll go to the Boulder trap. 8 00:00:17,770 --> 00:00:19,060 Here's my boulder. 9 00:00:19,060 --> 00:00:23,830 And I think what I'm going to do is I'm going to make this one invisible and then I'm just going to 10 00:00:23,830 --> 00:00:27,310 clone new ones when I go to reset the trap. 11 00:00:27,310 --> 00:00:27,660 Right? 12 00:00:27,670 --> 00:00:29,470 So I got the boulder the way I want it. 13 00:00:29,770 --> 00:00:33,280 I'm going to go here with that selected, go to transparency. 14 00:00:33,280 --> 00:00:34,810 Make that one. 15 00:00:34,810 --> 00:00:40,930 Right now we can't see the boulder and then let's go down to can collide. 16 00:00:40,930 --> 00:00:42,010 Uncheck that. 17 00:00:42,010 --> 00:00:48,070 Now we can't touch the boulder and then we'll go to anchored and we'll anchor it. 18 00:00:48,070 --> 00:00:49,690 And now it's not going to move. 19 00:00:49,690 --> 00:00:51,070 That is my template. 20 00:00:51,070 --> 00:00:55,630 We can't see it, but we're going to make new boulders from that one and then make them visible when 21 00:00:55,630 --> 00:00:56,260 we need them. 22 00:00:56,620 --> 00:01:01,150 So let's go to our trigger it now, Right? 23 00:01:01,450 --> 00:01:02,070 Boom. 24 00:01:02,110 --> 00:01:03,790 Oh, it's a new Roblox update. 25 00:01:03,790 --> 00:01:05,230 I'm just going to do a second time. 26 00:01:05,230 --> 00:01:05,980 There we go. 27 00:01:07,990 --> 00:01:10,660 Let's get a variable for our Boulder template. 28 00:01:11,050 --> 00:01:13,690 Boulder template. 29 00:01:13,930 --> 00:01:18,320 And that's in the Boulder Trap dot Boulder. 30 00:01:18,340 --> 00:01:22,050 The thing we just changed and then we're going to get another variable. 31 00:01:22,060 --> 00:01:24,290 I'm going to call those curve Boulder. 32 00:01:24,310 --> 00:01:27,730 That's going to be my current boulder that I cloned from my Boulder template. 33 00:01:28,870 --> 00:01:29,650 There we go. 34 00:01:29,650 --> 00:01:34,090 And I need a balance flag to prevent things from firing. 35 00:01:34,120 --> 00:01:38,190 Too often we only want to fire it after we reset the trap. 36 00:01:38,200 --> 00:01:43,380 So I'm going to say local can trigger and we could set that to false. 37 00:01:43,390 --> 00:01:45,880 Don't worry, we're going to turn it on when we start the game. 38 00:01:47,650 --> 00:01:50,560 I'm going to need something called the debris service. 39 00:01:50,560 --> 00:01:51,090 Right. 40 00:01:51,100 --> 00:02:00,670 So we'll make a variable debris, gain colon, get service debris, the debris service you can use to 41 00:02:00,670 --> 00:02:03,100 clean objects up after a period of time. 42 00:02:03,100 --> 00:02:05,530 It destroys them after a given period of time. 43 00:02:05,530 --> 00:02:10,540 So I'm going to destroy the boulder after I create it, after it rolls off into oblivion. 44 00:02:11,200 --> 00:02:11,530 All right. 45 00:02:11,530 --> 00:02:16,210 Now we'll do this function local function called set trap. 46 00:02:16,540 --> 00:02:18,220 What are we going to do is set trap. 47 00:02:18,220 --> 00:02:19,960 We're going to make a boulder first. 48 00:02:19,960 --> 00:02:22,690 So I'll say kerb older. 49 00:02:25,430 --> 00:02:32,560 And that's going to be from the Boulder template, Colon Cloud. 50 00:02:32,570 --> 00:02:34,450 So this does a deep clone. 51 00:02:34,460 --> 00:02:40,040 It's going to make exact copy of a bolder template, including being invisible, but also any scripts 52 00:02:40,040 --> 00:02:41,600 or sounds underneath it, too. 53 00:02:41,630 --> 00:02:44,390 That's kind of convenient, but it is invisible. 54 00:02:44,390 --> 00:02:50,300 So let's get our cover bolder and then make it visible so transparency will now equal zero. 55 00:02:51,290 --> 00:02:54,010 Curve older, remember can collide. 56 00:02:54,020 --> 00:03:02,180 We need to turn that onto malicious people so we have can collide is true kerb older anchored. 57 00:03:02,180 --> 00:03:04,160 We need to make that. 58 00:03:04,840 --> 00:03:05,410 Ball. 59 00:03:05,440 --> 00:03:13,150 So it rolls down the ramp and then we need curb, boulders, parent to be somewhere in the workspace 60 00:03:13,150 --> 00:03:14,200 or else we won't see it. 61 00:03:14,210 --> 00:03:15,840 It won't appear in the workspace. 62 00:03:15,850 --> 00:03:24,790 So I think I'll make the parent the bolder trap because that is in the workspace, the stoppers, right? 63 00:03:24,790 --> 00:03:30,550 So when we touched our when we touched our trigger plate, we made the stopper can collide false and 64 00:03:30,550 --> 00:03:31,660 we made it invisible. 65 00:03:32,200 --> 00:03:39,070 Well, we've got to reset those so we'll say stopper can collide. 66 00:03:40,180 --> 00:03:43,130 Set that to true or we'll keep it true. 67 00:03:43,150 --> 00:03:51,000 If we're starting up the game, we'll get the stopper transparency, we'll make that equal to zero. 68 00:03:51,010 --> 00:03:52,480 Now, this is going to be kind of tricky. 69 00:03:52,480 --> 00:03:58,060 What I'm going to do is I'm going to get the curb older dot destroying. 70 00:03:58,060 --> 00:04:05,350 I'm going to capture the destroying method when I create my boulder and I'm going to connect it, I 71 00:04:05,350 --> 00:04:08,290 should say I'm going to catch the destroying event. 72 00:04:08,290 --> 00:04:12,550 I'm going to connect it to an anonymous function is going to be crazy. 73 00:04:12,910 --> 00:04:15,550 That's going to call set trap. 74 00:04:15,550 --> 00:04:21,580 So when I destroy a boulder, I'm resetting my trap by calling set trap. 75 00:04:21,580 --> 00:04:23,800 So this isn't going to fire right away. 76 00:04:23,800 --> 00:04:31,210 I am just connecting the destroying event on the current boulder to do this. 77 00:04:31,210 --> 00:04:33,340 Actually, we could do even less than that. 78 00:04:33,340 --> 00:04:34,750 We could do this. 79 00:04:34,840 --> 00:04:37,270 But I was thinking of putting more in there than that. 80 00:04:39,730 --> 00:04:40,450 There we go. 81 00:04:40,630 --> 00:04:43,450 Connect it to set trap calls it again. 82 00:04:43,450 --> 00:04:44,590 Pretty crazy, huh? 83 00:04:44,980 --> 00:04:46,600 All right, now let's do this. 84 00:04:46,600 --> 00:04:49,270 Let's get the can trigger and we'll set it to true. 85 00:04:49,270 --> 00:04:50,740 Everything is ready to go. 86 00:04:51,430 --> 00:04:55,120 Well, when we go down to on touch, what's going to happen there? 87 00:04:55,900 --> 00:04:56,500 Let's see. 88 00:04:56,650 --> 00:05:01,480 We free up our boulder by making the stoppers can collide. 89 00:05:01,480 --> 00:05:01,960 False. 90 00:05:01,960 --> 00:05:03,550 And the transparency to one. 91 00:05:03,550 --> 00:05:04,510 I got rid of that space. 92 00:05:04,510 --> 00:05:05,350 I didn't like it. 93 00:05:06,070 --> 00:05:14,140 What I'm going to do is I'm also going to get the can trigger set that to false right. 94 00:05:14,140 --> 00:05:23,980 And that way when we touch our pressure plate, if can trigger is true, will be OC, then we'll go 95 00:05:23,980 --> 00:05:24,580 in here. 96 00:05:24,580 --> 00:05:30,550 But once I trigger it, I don't want to be able to fire this if statement off again until I reset it 97 00:05:30,550 --> 00:05:31,450 somewhere else. 98 00:05:31,450 --> 00:05:32,350 Where? 99 00:05:32,830 --> 00:05:34,120 Right in here. 100 00:05:34,660 --> 00:05:38,080 Once we make the fall or the boulder, we're going to say, Oh, it's true. 101 00:05:38,080 --> 00:05:39,700 Now we can trigger it again. 102 00:05:39,880 --> 00:05:41,590 That's kind of that's kind of cool. 103 00:05:41,590 --> 00:05:42,370 I like that. 104 00:05:43,030 --> 00:05:43,360 All right. 105 00:05:43,360 --> 00:05:44,950 What else are we going to do down here? 106 00:05:44,950 --> 00:05:47,200 We're going to say debris. 107 00:05:47,230 --> 00:05:53,860 We're going to get our debris variable, add item, boulder, and then the second value. 108 00:05:53,860 --> 00:05:56,260 So we're going to add the debris. 109 00:05:56,260 --> 00:06:00,580 So we're going to add the current boulder to the debris service and give it a time to live. 110 00:06:00,610 --> 00:06:02,140 The lifetime is in seconds. 111 00:06:02,140 --> 00:06:03,520 So I'm going to say 8 seconds. 112 00:06:03,520 --> 00:06:04,840 That works out for me. 113 00:06:05,620 --> 00:06:10,780 You don't want it to live too long because it rolls off the edge and then it goes out of scope of the 114 00:06:10,780 --> 00:06:12,670 game and is destroyed by the game. 115 00:06:12,670 --> 00:06:15,940 The destroying event is not going to fire. 116 00:06:15,970 --> 00:06:23,050 You have to actually destroy it with the debris service or the colon destroy method on the current boulder. 117 00:06:23,050 --> 00:06:24,310 So this will work. 118 00:06:24,310 --> 00:06:25,930 Don't make this too long. 119 00:06:25,930 --> 00:06:30,010 If it's too short, it'll look funny because it'll disappear before it's out of view. 120 00:06:30,790 --> 00:06:31,900 I think we're good. 121 00:06:32,170 --> 00:06:33,310 Oh, you know what, though? 122 00:06:33,310 --> 00:06:39,910 We still have to call this an initial time because we have it set up so that every time it destroys, 123 00:06:39,910 --> 00:06:40,960 we're going to call it again. 124 00:06:40,960 --> 00:06:42,460 But we've got to call it at least once. 125 00:06:42,460 --> 00:06:45,490 I'm going to call it down all the way down at the bottom. 126 00:06:46,360 --> 00:06:47,170 Let's do it. 127 00:06:52,910 --> 00:06:54,500 All right, Where's my boulder trap? 128 00:06:54,530 --> 00:06:55,370 Here it is. 129 00:06:56,210 --> 00:06:58,190 We're going to hit our pressure plate. 130 00:06:58,910 --> 00:06:59,850 Get out of the way. 131 00:06:59,870 --> 00:07:01,040 It won't hurt us anyway. 132 00:07:01,280 --> 00:07:02,540 We need to anchor that. 133 00:07:02,660 --> 00:07:03,910 As soon as that. 134 00:07:03,920 --> 00:07:06,890 That kind of bounced around, it disappeared. 135 00:07:07,220 --> 00:07:07,790 Boom! 136 00:07:07,790 --> 00:07:08,170 There it is. 137 00:07:08,220 --> 00:07:08,930 Made a new one. 138 00:07:09,140 --> 00:07:11,450 So I don't know if we'll be able to catch that. 139 00:07:12,260 --> 00:07:13,850 Maybe if we back up really far. 140 00:07:13,880 --> 00:07:14,660 There we go. 141 00:07:14,690 --> 00:07:15,890 Let's see what happens. 142 00:07:18,660 --> 00:07:19,080 Yeah. 143 00:07:19,080 --> 00:07:23,280 So you could actually even make that like one or 2 seconds longer because it destroyed right as it hit 144 00:07:23,280 --> 00:07:23,850 the edge. 145 00:07:23,850 --> 00:07:24,960 But I like it. 146 00:07:24,960 --> 00:07:26,360 I think it works pretty good. 147 00:07:26,370 --> 00:07:33,090 Let's go ahead and get this pressure plate and anchor it and then we'll be done for this video. 148 00:07:33,090 --> 00:07:37,410 We'll add sound and damage in the next one. 149 00:07:37,650 --> 00:07:42,390 We hit the alt key and select that, and that's going to select that in here. 150 00:07:42,390 --> 00:07:44,400 That's a little a little cheat. 151 00:07:44,400 --> 00:07:45,420 It's kind of cool. 152 00:07:46,300 --> 00:07:49,600 Let's go ahead and make that anchored so I don't flop around. 153 00:07:51,570 --> 00:07:52,510 Cool beans. 154 00:07:52,530 --> 00:07:54,500 I will see you in the next video. 155 00:07:54,510 --> 00:07:55,980 Sound and damage.